<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<!-- <div th:include="common/fwb-modal :: fwb-modal" />
<div th:include="common/xypl-modal :: xypl-modal" />
<div th:include="common/zj-modal :: zj-modal" />
<div th:include="common/bgfwbpl-modal :: bgfwbpl-modal" />
<div th:include="common/common-export :: common-export" /> -->


<!-- <link th:href="${quickJs}+'scripts/jquery/plug-ins/bootstrap-table/bootstrap-table.min.css'" rel="stylesheet"/>
<script th:src="${quickJs}+'scripts/jquery/plug-ins/bootstrap-table/bootstrap-table.min.js'"></script>
<link rel="stylesheet" th:href="${appName} + 'css/bootstrap-select.min.css'"/>	
<script th:src="${appName} + 'js/bootstrap-select.min.js'"></script>		 		 
<script th:src="${quickJs}+'scripts/jquery/plug-ins/bootstrap-table/bootstrap-table-zh-CN.min.js'"></script> -->
<script th:src="@{/service/js/jtqy.js}"></script>
	 		 
<title>医生签约统计</title>
<style type="text/css">
body{
	padding: 0px 0px;
}
.north{
	padding:8px 0px;
	background:#f9f9f9;
	overflow:hidden;
}
.table>tbody>tr>td{
	vertical-align: middle!important;
    text-align: center!important;
}
.spanBtn{
	font-weight: bold;
	color: blue;
	cursor:pointer;
}

.form-table select {
    width: 100%;
}
.timeLeft{
	width:36% !important;
	border: 1px solid #B6B6B6;
}
.timeRight{
	width:36% !important;
	float:right;
	border: 1px solid #B6B6B6;
}
.timeSpan{
	display:inline-block;
	width:4%;
	text-align:right;
}
</style>
</head>
<script th:inline="javascript">
    /**读取request中的初始化数据*/
	var requestData = [[${requestData}]];
</script>
<script type="text/javascript">
$(function() {
 	initView();
 	initData();
});

/**
*
*/
function queryForm() {
	$("#dgForm").datagrid({"url":  contextRoot+"qytj/queryTjxxPage.service" });
}

function initData(){
    if(!requestData["isManager"]){
        $("#combogridYljg").combogrid("grid").datagrid("loadData", [requestData]);
        $("#combogridYljg").combogrid("setValue", requestData);
    }
    queryForm();
}
function queryHandler() {
	$("#dgForm").datagrid("load");
}
function queryReload(){
	$("#dgForm").datagrid("reload");
}

/*function initDate(){
	$(".form-control").CacheForSelect();
	fwbDataSelectInit();
	var endTimeObj = {
			elem: '#QYJSSJ',
		  	choose: function(datas){
		  		startTimeObj.max = datas;
		    }
	};
	laydate(endTimeObj);
	//生效日期
	var startTimeObj = {
		 elem: '#QYKSSJ',
	  	 choose: function(datas){
	  		endTimeObj.min = datas;
	  	 }
	};
	laydate(startTimeObj);
}*/

function initView()
{
	//回车查询
	enterToQuery(queryHandler);
	
	$("#dgForm").datagrid({
		idField : "QYXXID",
		striped : true,
		singleSelect : true,
		fit:true,
		fitColumns:true,
		columns : [[
			{
				field : "YLJGMC",
				title : "机构名称"
				,width:20
				,formatter: function(value,row){
					return formatTitle(value);
				}
			},
			{
				field : "TDMC",
				title : "签约团队"
				,width:10
                ,formatter: function(value,row){
					return formatTitle(value);
				}
			},
			{
				field : "YSXM",
				title : "医生姓名",
				width:8
			},
			{
				field : "QYCS",
				title : "签约次数"
				,width:5
				,formatter: function(value,row){
                	var options = $.extend({TO : "qyList" , value : value , SJLX : "01"} , row);
//				    var options = {value : value , TO : "qyList" , SJGLID : row.QYCSID};
//                	options = JSON.stringify(options).replace(/"/g, '&quot;');
					return createFunctionSpan(options);
				}
			},
			{
				field : "XYCS",
				title : "续约次数",
				width:5,
				formatter: function(value,row){
//                    var options = {value : value , TO : "xyList" , SJGLID : row.XYCSID};
                    var options = $.extend({TO : "xyList" , value : value , SJLX : "02"} , row);
                    return createFunctionSpan(options);
				}
			},
			{
				field : "ZJCS",
				title : "转介次数"
				,width:5
				,formatter: function(value,row){
//					var options = {value : value , TO : "zjList" , SJGLID : row.ZJCSID};
                	var options = $.extend({TO : "zjList" , value : value , SJLX : "03"} , row);
					return createFunctionSpan(options);
				}
			},
			{
				field : "BGCS",
				title : "变更次数",
				width:5,
				formatter : function(value, row, index) {
//                    var options = {value : value , TO : "bgList" , SJGLID : row.BGCSID};
                    var options = $.extend({TO : "bgList" , value : value , SJLX : "04"} , row);
                    return createFunctionSpan(options);
				}
			},
			{
				field : "JYCS",
				title : "解约次数",
				width:5,
				formatter : function(value, row, index){
//                    var options = {value : value , TO : "jyList" , SJGLID : row.JYCSID};
                    var options = $.extend({TO : "jyList" , value : value , SJLX : "05"} , row);
                    return createFunctionSpan(options);
				}
			}
		]]
		,pagination : true
		,pageSize : 10
		,pageList: [10, 20, 50, 100, 200]
		,method : "post"
		,onBeforeLoad: function(params){
            var url = $(this).datagrid("options")["url"];
            if(!StringUtils.isEmpty(url)){
                var yljgxx = getQueryFormValue();
                params = $.extend(params,yljgxx);
                getContainerDataByClassName('conditionBox','form-control',params);//查询条件
                return true;
            }else{
                return false;
            }
		}
	
	});

    var readonly = !requestData["isManager"];
    $("#combogridYljg").combogrid({
        height: 30
        ,width: 250
        ,panelWidth: 500
        ,singleSelect: true
        ,pagination: true
        ,idField: 'YLJGDM'
        ,textField: 'YLJGMC'
        ,mode: "remote"
        ,readonly: readonly
        ,hasDownArrow: !readonly
        ,url: "/console/yljgxx/queryPageSummary.service"
        ,delay: 1000
        ,reversed: false
        ,columns:[[
            {
                field:'YLJGMC'
                ,title:'机构名称'
                ,width:240
            }
            ,{
                field:'XZQHMC'
                ,title:'行政区划'
                ,width:80
            }
            ,{
                field:'WSJGLBMC'
                ,title:'机构类别'
                ,width:80
            }
            ,{
                field:'YYDJMC'
                ,title:'机构等级'
                ,width:80
            }
        ]]
        ,onBeforeLoad: function(queryParams) {
            var url = $(this).datagrid("options")["url"];
			/*URL不等空时再发送请求*/
            if (!readonly) {
                queryParams["pageSize"] = queryParams["rows"];
                queryParams["pageNumber"] = queryParams["page"];
                queryParams["YLJGMC"] = queryParams["q"];
                return true;
            }else{
                return false;
            }
        },
        onLoadSuccess : function(data){

        }
    });

}

function createFunctionSpan(options){
    var value = options.value;
    if(value == "0"){
        return value;
    }else{
        options = JSON.stringify(options).replace(/"/g, '&quot;');
//        return '<span class="spanBtn" onclick=openQysjxx("' + options.TO + '","' + options.SJGLID + '")>' + value + '</span>';
        return '<span class="spanBtn" onclick="openQysjxx(' + options + ')">' + value + '</span>';
    }
}

function openQysjxx(options){
//    alert(JSON.stringify(options));
//    parent.layer.open({
//        type : 2,
//        title : "签约事件信息",
//        shadeClose : false,
//        shade : 0.8,
//        area : [ "90%", "80%" ],
//        content: contextRoot + 'qytj/toQysjxq.html?TO=' + options.TO + '&PTJGID=' + options.PTJGID + "&TDID=" + options.TDID + "&YSID=" + options.YSID +
//			"&SJLX=" + options.SJLX
//    });
    window.open(contextRoot + 'qytj/toQysjxq.html?TO=' + options.TO + '&PTJGID=' + options.PTJGID + "&TDID=" + options.TDID + "&YSID=" + options.YSID +
        "&SJLX=" + options.SJLX);
}

/** 获取已选中的记录  */
function getCheckedRows(){
    var selection = $("#dgForm").datagrid("getChecked");
    return selection;
}

/**获取查询表单的值*/
function getQueryFormValue() {
    var params = {};
    var item = $("#combogridYljg").combogrid("grid").datagrid("getSelected");
    if(item){
        params["PTJGID"] = item["PTJGID"];
    }else{
        params["YLJGMC"] = $("#combogridYljg").combogrid("getText");
    }
    return params;
}

</script>
<body class="easyui-layout" fit="true" border="false">
	<div region="north" style="border: none; overflow: hidden; background-color: #f9f9f9;">
		<div style="width: 100%; margin-left: 30px">
			<h3 style="text-align:center;line-height: 41px; margin: 0px; font-size: 18px;font-weight: bold;">签约统计列表</h3>
		</div>
			
			<!-- 打印 -->
			<form id="printForm" action="printXy.service" enctype="multipart/form-data" style="display:none">
				<input name="QYXXIDS" id="QYXXIDS" type="hidden">
			</form>
			
			<!-- 导出 -->
			<form id="exportForm" action="export.service" enctype="multipart/form-data">
				<table class="form-table" id="conditionBox">
					<tr>
						<td class="td-text">机构名称：</td>
						<td class="td-content">
							<input id="combogridYljg"/>
						</td>
						<td class="td-text">团队名称：</td>
						<td class="td-content">
							<input id="QYTD" name="QYTD" class="form-control dataField" type="text" style="width: 100%;"
							>
						</td>
						<td class="td-text">医生姓名：</td>
						<td class="td-content">
							<input id="XM" name="XM" class="form-control dataField" type="text" style="width: 100%;"
							>
						</td>
						<td class="td-text" style="text-align:center;width:150px;">
							<button id="btnQuery" class="btn btn-info" type="button" id="btnQueryFwb" onclick="queryHandler()">查询</button>
						</td>
					</tr>

				</table>
			</form>
		<div style="margin:10px auto 10px 29px;">

		</div>
	</div>
	<div region="center" border="false" >
		<table id="dgForm"></table>
	</div>
</body>
</html>
